package service

type Directory struct {
	DirTag     string   `json:"dir_tag"`
	Path       string   `json:"path"`
	WriterList []string `json:"writer_list"`
}

func (d *Directory) MakeDir() (err error) {
	//创建目录
	_, err = SendCmd("mkdir -p " + d.Path)
	if err != nil {
		return err
	}
	//设置权限
	_, err = SendCmd("chown crow.crow " + d.Path + " &&  chmod 775 " + d.Path)
	if err != nil {
		return err
	}
	return nil
}

func (d *Directory) Set(dirTag string, dirPath string, WriterList []string) {
	d.DirTag = dirTag
	d.Path = dirPath
	if len(WriterList) != 0 {
		d.WriterList = WriterList
	}
}
